package com.caszx.chargingpile.fragment.station;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import com.app.base.fragment.BaseFragment;
import com.caszx.chargingpile.R;
import com.caszx.chargingpile.entity.EntityTabStationDetail;

/**电桩详情*/
public class TabDetailFragment extends BaseFragment {


   private  EntityTabStationDetail entity;
    private TextView txt_station_name ;
    private TextView txt_station_code ;
    private TextView txt_station_address ;
    private TextView txt_station_config ;
    private TextView txt_station_time ;

    public static TabDetailFragment newInstance(EntityTabStationDetail entity) {
        TabDetailFragment fragment = new TabDetailFragment();

        Bundle bundle = new Bundle();
        bundle.putSerializable("DETAIL",entity);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            entity = (EntityTabStationDetail) getArguments().getSerializable("DETAIL");
        }
    }

    @Override
    protected View initView() {
        View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_tab_detail,null);
        findViewById(view);
        setData();
        return view;
    }

    private void findViewById(View view){
        txt_station_name = (TextView) view.findViewById(R.id.txt_station_name);
        txt_station_code = (TextView) view.findViewById(R.id.txt_station_code);
        txt_station_address = (TextView) view.findViewById(R.id.txt_station_address);
        txt_station_config = (TextView) view.findViewById(R.id.txt_station_config);
        txt_station_time = (TextView) view.findViewById(R.id.txt_station_time);
    }

    private void setData(){
        if(entity == null) return;

        txt_station_name.setText(entity.name);
        txt_station_code.setText("编号:"+entity.code);
        txt_station_address.setText("地址:"+entity.address);
        txt_station_config.setText(entity.fast+"个快充  "+entity.slow+"个慢充");
        txt_station_time.setText("建立时间:"+entity.createDate);
    }

}
